// import React, { Component } from 'react'
import React from 'react'

import {
    Switch,
    Route,
    Redirect
} from 'react-router-dom'

// export default class RouterView extends Component {

//     static defaultProps = {
//         routes: []
//     }
//     render() {

//         const { routes } = this.props
//         return (
//             <Switch>
//                 {
//                     routes.length && routes.map((item, idx) => {
//                         return item.path ? <Route key={idx} path={item.path} render={(props) => <item.component {...props} routes={item.children} />} />
//                         : <Redirect key={idx} exact from={item.from} to={item.to} />
//                     })
//                 }
//             </Switch>
//         )
//     }
// }
export default function RouterView(props) {
    const { routes = [] } = props
    return (
        <Switch>
            {
                routes.length && routes.map((item, idx) => {
                    return item.path ? <Route key={idx} path={item.path} render={(props) => <item.component {...props} routes={item.children} />} />
                        : <Redirect key={idx} {...item} exact />
                })
            }
        </Switch>
    )
}
